/*
 * @(#)MCCIIN000002UV01Transformer.java
 * Date 2013-08-24
 * Version 1.0
 * Author Jim Horner
 * Copyright (c)2012
 */


package us.hornerscorners.lamppost.registry.transformer.hl7;

import javax.enterprise.context.ApplicationScoped;

import javax.inject.Inject;

import org.hl7.v3.MCCIIN000002UV01;
import org.hl7.v3.PRPAIN201301UV02;
import us.hornerscorners.lamppost.config.IServiceConfig;

import us.hornerscorners.lamppost.hl7v3common.constant.AckResponse;
import us.hornerscorners.lamppost.hl7v3common.constant.AckSetting;

import us.hornerscorners.lamppost.hl7v3common.constant.HL7Constant;
import us.hornerscorners.lamppost.hl7v3common.constant.Interaction;
import us.hornerscorners.lamppost.hl7v3common.constant.ProcessingCode;
import us.hornerscorners.lamppost.hl7v3common.constant.ProcessingMood;

import us.hornerscorners.lamppost.hl7v3common.transformer.CSTransformer;
import us.hornerscorners.lamppost.hl7v3common.transformer.IITransformer;
import us.hornerscorners.lamppost.hl7v3common.transformer.MCCIMT000200UV01Transformer;
import us.hornerscorners.lamppost.hl7v3common.transformer.TSTransformer;


/**
 *
 * @author jim
 */
@ApplicationScoped
public class MCCIIN000002UV01Transformer {

    /** Field description */
    @Inject
    private CSTransformer csTransformer;

    /** Field description */
    @Inject
    private IITransformer iiTransformer;

    /** Field description */
    @Inject
    private MCCIMT000200UV01Transformer mccimtTransformer;

    /** Field description */
    @Inject
    private TSTransformer tsTransformer;

    /**
     * Constructs ...
     *
     */
    public MCCIIN000002UV01Transformer() {
        super();
    }

    /**
     * Method description
     *
     *
     * @param config
     * @param prpa301
     * @param success
     *
     * @return
     */
    public MCCIIN000002UV01 transform(IServiceConfig config, PRPAIN201301UV02 prpa301,
                                      boolean success) {

        MCCIIN000002UV01 result = new MCCIIN000002UV01();

        result.setITSVersion(HL7Constant.ITSVersion.getCode());
        result.setId(this.iiTransformer.createRandomII());
        result.setCreationTime(this.tsTransformer.createNowTS());
        result.setVersionCode(this.csTransformer.transform(HL7Constant.VersionCode));
        result.setInteractionId(
            this.iiTransformer.transform(Interaction.MCCI_IN000002UV01));
        result.setProcessingCode(this.csTransformer.transform(ProcessingCode.Production));
        result.setProcessingModeCode(
            this.csTransformer.transform(ProcessingMood.CurrentProcessing));
        result.setAcceptAckCode(this.csTransformer.transform(AckSetting.Never));

        // Receiver
        result.getReceiver().add(this.mccimtTransformer.transform(prpa301));

        // Sender
        result.setSender(this.mccimtTransformer.transform(config));

        // Acknowledgement
        result.getAcknowledgement().add(this.mccimtTransformer.transform(prpa301,
                AckResponse.CommitAck));

        return result;
    }
}
